﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using W.Common.Enum;
using W.Warehouse.Api.Application.Command.StorageCommand;
using W.Warehouse.Domain.DTO;
using W.Warehouse.Read.Api.Application.Command.AllocationCommand;
using W.Warehouse.Read.Api.Application.Command.MoveCommand;

namespace W.Warehouse.Read.Api.Controllers
{
    /// <summary>
    /// 移库
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MoveController : ControllerBase
    {
        private readonly IMediator mediator;
        public MoveController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 单据类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public dynamic GetAuditStatus()
        {
            return Enum.GetValues(typeof(AuditStatus))
                .Cast<AuditStatus>()
                .Select(x => new
                {
                    Value = (int)x,
                    Text = x.ToString()
                }).ToList();
        }
        ///// <summary>
        ///// 列表显示
        ///// </summary>
        ///// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<MovepageDTO>> MoveShow([FromQuery] MoveShowCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 反填移库信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<FanMoveDTO>> FanStorage([FromQuery] MoveFanCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
